﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:view="clr-namespace:RegExUtility.View"
                    xmlns:viewModel="clr-namespace:RegExUtility.ViewModel;assembly=RegexUtility.ViewModel">

    <DataTemplate DataType="{x:Type viewModel:DirectoryInputViewModel}">
        <view:DirectoryInputView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type viewModel:LiteralTextInputViewModel}">
        <view:LiteralTextInputView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type viewModel:MultipleFilesInputViewModel}">
        <view:MultipleFilesInputView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type viewModel:RegistryInputViewModel}">
        <view:RegistryInputView />
    </DataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexMatchesViewModel}"
                              ItemsSource="{Binding }">
        <TextBlock Text="{Binding Path=Count, StringFormat='{}Matches ({0})'}" />
    </HierarchicalDataTemplate>

    <DataTemplate x:Key="RegexMatchValueDataTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Border Grid.Column="1"
                    Background="#EDF7FF"
                    BorderBrush="#556D7F"
                    BorderThickness="4,0"
                    HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=Match.Value}"
                           Foreground="Black"
                           FontFamily="Consolas" />
            </Border>

        </Grid>
    </DataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexMatchViewModel}"
                              ItemsSource="{Binding}">
        <ContentControl Content="{Binding }"
                        ContentTemplate="{StaticResource RegexMatchValueDataTemplate}"
                        Grid.Row="1"
                        Grid.ColumnSpan="2">
            <ContentControl.ToolTip>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="Match"
                               Margin="0,0,8,0"
                               VerticalAlignment="Top" />

                    <Grid Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="{Binding Path=Match.Success, StringFormat='{}Success: {0}'}"
                                   Grid.Row="0"
                                   Grid.ColumnSpan="2" />

                        <ContentControl Content="{Binding }"
                                        ContentTemplate="{StaticResource RegexMatchValueDataTemplate}"
                                        Grid.Row="1"
                                        Grid.ColumnSpan="2" />

                        <TextBlock Text="{Binding Path=Match.Index, StringFormat='{}Index: {0}  '}"
                                   Grid.Row="2" />

                        <TextBlock Text="{Binding Path=Match.Length, StringFormat='{}Length: {0}'}"
                                   Grid.Row="2"
                                   Grid.Column="1" />
                    </Grid>
                </Grid>
            </ContentControl.ToolTip>
        </ContentControl>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexCapturesViewModel}"
                              ItemsSource="{Binding }">
        <TextBlock Text="{Binding Path=Count, StringFormat='{}Captures ({0})'}" />
    </HierarchicalDataTemplate>

    <DataTemplate x:Key="RegexCaptureValueDataTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Border Grid.Column="1"
                    Background="#FEFFED"
                    BorderBrush="#7E7F55"
                    BorderThickness="4,0"
                    HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=Capture.Value}"
                           Foreground="Black"
                           FontFamily="Consolas" />
            </Border>

        </Grid>
    </DataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexCaptureViewModel}"
                              ItemsSource="{Binding}">
        <ContentControl Content="{Binding }"
                        ContentTemplate="{StaticResource RegexCaptureValueDataTemplate}"
                        Grid.Row="1"
                        Grid.ColumnSpan="2">
            <ContentControl.ToolTip>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="Capture"
                               Margin="0,0,8,0"
                               VerticalAlignment="Top" />

                    <Grid Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="{Binding Path=Capture.Success, StringFormat='{}Success: {0}'}"
                                   Grid.Row="0"
                                   Grid.ColumnSpan="2" />

                        <ContentControl Content="{Binding }"
                                        ContentTemplate="{StaticResource RegexCaptureValueDataTemplate}"
                                        Grid.Row="1"
                                        Grid.ColumnSpan="2" />

                        <TextBlock Text="{Binding Path=Capture.Index, StringFormat='{}Index: {0}  '}"
                                   Grid.Row="2" />

                        <TextBlock Text="{Binding Path=Capture.Length, StringFormat='{}Length: {0}'}"
                                   Grid.Row="2"
                                   Grid.Column="1" />
                    </Grid>
                </Grid>
            </ContentControl.ToolTip>
        </ContentControl>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexGroupsViewModel}"
                              ItemsSource="{Binding }">
        <TextBlock Text="{Binding Path=Count, StringFormat='{}Groups ({0})'}" />
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexNamedGroupsViewModel}"
                              ItemsSource="{Binding }">
        <TextBlock Text="{Binding Path=Count, StringFormat='{}Named Groups ({0})'}" />
    </HierarchicalDataTemplate>

    <DataTemplate x:Key="RegexNamedGroupValueDataTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <TextBlock Text="{Binding Path=Name, StringFormat='{}&quot;{0}&quot; = '}" />

            <Border Grid.Column="1"
                    Background="#F5EDFF"
                    BorderBrush="#69557F"
                    BorderThickness="4,0"
                    HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=Group.Value}"
                           Foreground="Black"
                           FontFamily="Consolas" />
            </Border>

        </Grid>
    </DataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexNamedGroupViewModel}"
                              ItemsSource="{Binding }">
        <ContentControl Content="{Binding }"
                        ContentTemplate="{StaticResource RegexNamedGroupValueDataTemplate}">
            <ContentControl.ToolTip>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="Group"
                               Margin="0,0,8,0"
                               VerticalAlignment="Top" />

                    <Grid Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="{Binding Path=Name, StringFormat='{}Name: {0}'}"
                                   Grid.Row="0"
                                   Grid.ColumnSpan="2" />

                        <TextBlock Text="{Binding Path=Group.Success, StringFormat='{}Success: {0}'}"
                                   Grid.Row="1"
                                   Grid.ColumnSpan="2" />

                        <ContentControl Content="{Binding }"
                                        ContentTemplate="{StaticResource RegexNamedGroupValueDataTemplate}"
                                        Grid.Row="2"
                                        Grid.ColumnSpan="2" />

                        <TextBlock Text="{Binding Path=Group.Index, StringFormat='{}Index: {0}  '}"
                                   Grid.Row="3" />

                        <TextBlock Text="{Binding Path=Group.Length, StringFormat='{}Length: {0}'}"
                                   Grid.Row="3"
                                   Grid.Column="1" />
                    </Grid>
                </Grid>
            </ContentControl.ToolTip>
        </ContentControl>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexNumberedGroupsViewModel}"
                              ItemsSource="{Binding }">
        <TextBlock Text="{Binding Path=Count, StringFormat='{}Numbered Groups ({0})'}" />
    </HierarchicalDataTemplate>

    <DataTemplate x:Key="RegexNumberedGroupValueDataTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <TextBlock Text="{Binding Path=Number, StringFormat='{}[{0}] = '}" />

            <Border Grid.Column="1"
                    Background="#F5EDFF"
                    BorderBrush="#69557F"
                    BorderThickness="4,0"
                    HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=Group.Value}"
                           Foreground="Black"
                           FontFamily="Consolas" />
            </Border>

        </Grid>
    </DataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type viewModel:RegexNumberedGroupViewModel}"
                              ItemsSource="{Binding }">
        <ContentControl Content="{Binding }"
                        ContentTemplate="{StaticResource RegexNumberedGroupValueDataTemplate}">
            <ContentControl.ToolTip>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="Group"
                               Margin="0,0,8,0"
                               VerticalAlignment="Top" />

                    <Grid Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="{Binding Path=Number, StringFormat='{}Number: {0}'}"
                                   Grid.Row="0"
                                   Grid.ColumnSpan="2" />

                        <TextBlock Text="{Binding Path=Group.Success, StringFormat='{}Success: {0}'}"
                                   Grid.Row="1"
                                   Grid.ColumnSpan="2" />

                        <ContentControl Content="{Binding }"
                                        ContentTemplate="{StaticResource RegexNumberedGroupValueDataTemplate}"
                                        Grid.Row="2"
                                        Grid.ColumnSpan="2" />

                        <TextBlock Text="{Binding Path=Group.Index, StringFormat='{}Index: {0}  '}"
                                   Grid.Row="3" />

                        <TextBlock Text="{Binding Path=Group.Length, StringFormat='{}Length: {0}'}"
                                   Grid.Row="3"
                                   Grid.Column="1" />
                    </Grid>
                </Grid>
            </ContentControl.ToolTip>
        </ContentControl>
    </HierarchicalDataTemplate>

</ResourceDictionary>
